const { injectBabelPlugin } = require('react-app-rewired')
const bodyParser = require('body-parser')

module.exports = {
  webpack: function(config, env) {
    config = injectBabelPlugin(
      ['import', { libraryName: 'antd', style: 'css' }],
      config
    )
    return config
  },
  devServer: function(configFunction) {
    return function(proxy, allowedHost) {
      const config = configFunction(proxy, allowedHost)
      config.before = app => {
        app.use(bodyParser.urlencoded({ extended: false }))
        app.use(bodyParser.json())
        app.use('', require('./mock/index'))
      }
      return config
    }
  }
}
